package App.widoki;

import App.kontrolery.KontrolerEdytujKontener;
import App.kontrolery.KontrolerGlowne;
import App.modele.ModelEdytujKontener;
import App.modele.ModelGlowne;
import java.awt.Color;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

/**
 *
 * @author Krzysiek
 */
public class WidokGlowne extends javax.swing.JFrame
{
    private ModelGlowne model = null;
    private KontrolerGlowne kontroler = null;

    public WidokGlowne(KontrolerGlowne kontroler, ModelGlowne model)
    {
        this.kontroler = kontroler;
        this.model = model;

        initComponents();       
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jButtonWczytajTerminal = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jButtonEdytujKontener = new javax.swing.JButton();
        jButtonPrzegladajTerminal = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenuPlik = new javax.swing.JMenu();
        jMenuItemZakoncz = new javax.swing.JMenuItem();
        jMenuTerminal = new javax.swing.JMenu();
        jMenuItemWczytajTerminal = new javax.swing.JMenuItem();
        jMenuZapiszTerminal = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jMenuWczytajTransport = new javax.swing.JMenuItem();
        jMenuItemPokazPlanowaneTransporty = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("System transportowy - Krzysztof Kędzierski 156425");
        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                formKeyPressed(evt);
            }
        });

        jTabbedPane1.setBackground(javax.swing.UIManager.getDefaults().getColor("Menu.selectionBackground"));

        jPanel3.setBackground(new java.awt.Color(102, 102, 255));

        jButtonWczytajTerminal.setText("Wczytaj Terminal");
        jButtonWczytajTerminal.setBorderPainted(false);
        jButtonWczytajTerminal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonWczytajTerminalActionPerformed(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(102, 255, 204));
        jPanel1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanel1MouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jPanel1MouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jPanel1MouseExited(evt);
            }
        });
        jPanel1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jPanel1KeyPressed(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jPanel1KeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 40, Short.MAX_VALUE)
        );

        jButtonEdytujKontener.setText("Edytuj kontener");
        jButtonEdytujKontener.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEdytujKontenerActionPerformed(evt);
            }
        });

        jButtonPrzegladajTerminal.setText("Przeglądaj Terminal");
        jButtonPrzegladajTerminal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPrzegladajTerminalActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jButtonEdytujKontener, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButtonPrzegladajTerminal, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButtonWczytajTerminal, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 375, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(49, 49, 49))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jButtonWczytajTerminal)
                        .addGap(5, 5, 5)
                        .addComponent(jButtonPrzegladajTerminal)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonEdytujKontener)
                .addContainerGap(140, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("tab3", jPanel3);

        jMenuPlik.setText("Plik");

        jMenuItemZakoncz.setText("Zakończ");
        jMenuItemZakoncz.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemZakonczActionPerformed(evt);
            }
        });
        jMenuPlik.add(jMenuItemZakoncz);

        jMenuBar1.add(jMenuPlik);

        jMenuTerminal.setText("Terminal");

        jMenuItemWczytajTerminal.setText("wczytaj");
        jMenuItemWczytajTerminal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemWczytajTerminalActionPerformed(evt);
            }
        });
        jMenuTerminal.add(jMenuItemWczytajTerminal);

        jMenuZapiszTerminal.setText("zapisz");
        jMenuZapiszTerminal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuZapiszTerminalActionPerformed(evt);
            }
        });
        jMenuTerminal.add(jMenuZapiszTerminal);

        jMenuBar1.add(jMenuTerminal);

        jMenu1.setText("Transporty");

        jMenuWczytajTransport.setText("wczytaj Transport");
        jMenuWczytajTransport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuWczytajTransportActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuWczytajTransport);

        jMenuItemPokazPlanowaneTransporty.setText("pokaż planowane transporty");
        jMenuItemPokazPlanowaneTransporty.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemPokazPlanowaneTransportyActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItemPokazPlanowaneTransporty);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 664, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(54, Short.MAX_VALUE)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formKeyPressed(java.awt.event.KeyEvent evt)//GEN-FIRST:event_formKeyPressed
    {//GEN-HEADEREND:event_formKeyPressed
        System.out.println("Typed2!");
    }//GEN-LAST:event_formKeyPressed

    private void jButtonEdytujKontenerActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonEdytujKontenerActionPerformed
    {//GEN-HEADEREND:event_jButtonEdytujKontenerActionPerformed
        ModelEdytujKontener edytujKontener = new ModelEdytujKontener(null);
        KontrolerEdytujKontener kontrolerEdytuj = new KontrolerEdytujKontener(edytujKontener);
        kontrolerEdytuj.start();
}//GEN-LAST:event_jButtonEdytujKontenerActionPerformed

    private void jPanel1KeyTyped(java.awt.event.KeyEvent evt)//GEN-FIRST:event_jPanel1KeyTyped
    {//GEN-HEADEREND:event_jPanel1KeyTyped
        System.out.println("Typed!");
}//GEN-LAST:event_jPanel1KeyTyped

    private void jPanel1KeyPressed(java.awt.event.KeyEvent evt)//GEN-FIRST:event_jPanel1KeyPressed
    {//GEN-HEADEREND:event_jPanel1KeyPressed
        System.out.println("Nacisnieto!");
        if(evt.isActionKey())
            jPanel1.setBackground(Color.pink);
}//GEN-LAST:event_jPanel1KeyPressed

    private void jPanel1MouseExited(java.awt.event.MouseEvent evt)//GEN-FIRST:event_jPanel1MouseExited
    {//GEN-HEADEREND:event_jPanel1MouseExited
        jPanel1.setBackground(Color.blue);
}//GEN-LAST:event_jPanel1MouseExited

    private void jPanel1MouseEntered(java.awt.event.MouseEvent evt)//GEN-FIRST:event_jPanel1MouseEntered
    {//GEN-HEADEREND:event_jPanel1MouseEntered
        jPanel1.setBackground(Color.red);
}//GEN-LAST:event_jPanel1MouseEntered

    private void jPanel1MouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_jPanel1MouseClicked
    {//GEN-HEADEREND:event_jPanel1MouseClicked
        JOptionPane.showMessageDialog(WidokGlowne.this, "Kliknięto przycisk");
}//GEN-LAST:event_jPanel1MouseClicked

    private void jButtonWczytajTerminalActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonWczytajTerminalActionPerformed
    {//GEN-HEADEREND:event_jButtonWczytajTerminalActionPerformed
        kontroler.wczytajTerminal();
}//GEN-LAST:event_jButtonWczytajTerminalActionPerformed

    private void jButtonPrzegladajTerminalActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonPrzegladajTerminalActionPerformed
    {//GEN-HEADEREND:event_jButtonPrzegladajTerminalActionPerformed
        kontroler.przegladajTerminal();
    }//GEN-LAST:event_jButtonPrzegladajTerminalActionPerformed

    private void jMenuItemZakonczActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jMenuItemZakonczActionPerformed
    {//GEN-HEADEREND:event_jMenuItemZakonczActionPerformed
       System.exit(0);
    }//GEN-LAST:event_jMenuItemZakonczActionPerformed

    private void jMenuItemWczytajTerminalActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jMenuItemWczytajTerminalActionPerformed
    {//GEN-HEADEREND:event_jMenuItemWczytajTerminalActionPerformed
       kontroler.wczytajTerminal();
    }//GEN-LAST:event_jMenuItemWczytajTerminalActionPerformed

    private void jMenuZapiszTerminalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuZapiszTerminalActionPerformed
        kontroler.zapiszTerminal();
    }//GEN-LAST:event_jMenuZapiszTerminalActionPerformed

    private void jMenuWczytajTransportActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jMenuWczytajTransportActionPerformed
    {//GEN-HEADEREND:event_jMenuWczytajTransportActionPerformed
        kontroler.wczytajTransport();
    }//GEN-LAST:event_jMenuWczytajTransportActionPerformed

    private void jMenuItemPokazPlanowaneTransportyActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jMenuItemPokazPlanowaneTransportyActionPerformed
    {//GEN-HEADEREND:event_jMenuItemPokazPlanowaneTransportyActionPerformed
        kontroler.pokazPlanowaneTransporty();
    }//GEN-LAST:event_jMenuItemPokazPlanowaneTransportyActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
           //     new WidokGlowne().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonEdytujKontener;
    private javax.swing.JButton jButtonPrzegladajTerminal;
    private javax.swing.JButton jButtonWczytajTerminal;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItemPokazPlanowaneTransporty;
    private javax.swing.JMenuItem jMenuItemWczytajTerminal;
    private javax.swing.JMenuItem jMenuItemZakoncz;
    private javax.swing.JMenu jMenuPlik;
    private javax.swing.JMenu jMenuTerminal;
    private javax.swing.JMenuItem jMenuWczytajTransport;
    private javax.swing.JMenuItem jMenuZapiszTerminal;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTabbedPane jTabbedPane1;
    // End of variables declaration//GEN-END:variables

}
